var t = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}(require("../../until/storage")), e = getApp();

Page({
    data: {
        kefu: "http://www.120kg.xyz/static/images/wxMovie/id-card.jpeg",
        videoAd: e.globalData.config.adConfig.videoAd,
        isAdd: !1,
        topShow: !1,
        isShow: !1,
        isLive: !1,
        isFlsShow: !1,
        list: [],
        toast: "",
        avatarUrl: "./user-unlogin.png",
        userInfo: {},
        logged: !1,
        takeSession: !1,
        requestResult: "",
        page: 1,
        key: "movie",
        href: "/movie/list/----h",
        index: 0,
        tabArr: [ {
            key: 1,
            value: "电影",
            select: 1,
            src: "movie"
        }, {
            key: 2,
            value: "电视剧",
            select: 0,
            src: "tv"
        }, {
            key: 3,
            value: "动漫",
            select: 0,
            src: "cmc"
        }, {
            key: 4,
            value: "综艺",
            select: 0,
            src: "zy"
        } ],
        currentTab: 0
    },
    close: function() {
        this.setData({
            isAdd: !1
        });
    },
    previewImage: function(t) {
        var e = t.target.dataset.src;
        wx.previewImage({
            current: e,
            urls: [ e ]
        });
    },
    goTop: function(t) {
        wx.pageScrollTo ? wx.pageScrollTo({
            scrollTop: 0
        }) : wx.showModal({
            title: "提示",
            content: "当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。"
        });
    },
    onPageScroll: function(t) {
        t.scrollTop > 300 ? this.setData({
            topShow: !0
        }) : this.setData({
            topShow: !1
        });
    },
    tipModal: function(t, e) {
        t && wx.showModal({
            title: "温馨提示",
            content: e,
            showCancel: !1,
            success: function(t) {
                t.confirm && console.log("用户点击确定");
            }
        });
    },
    onShow: function() {
        var a = this, s = e.globalData.config, o = s.showVersion, i = s.sessionVersion;
        wx.request({
            url: "https://www.120kg.xyz/wxMovieVersion",
            success: function(e) {
                if (o < +e.data[i].version) {
                    var s = e.data[i].homeShowModal, n = s.isShow, r = s.tipText, c = s.status;
                    if (a.setData({
                        isLive: !0,
                        isAdd: !0,
                        isFlsShow: e.data[i].isFlsShow,
                        homeShowModal: e.data[i].homeShowModal
                    }), n) {
                        var u = !0, l = wx.getStorageSync("tipModalStatus");
                        "tip" == c && (l ? u = !1 : t.default.set("tipModalStatus", "tip")), a.tipModal(u, r);
                    }
                } else a.setData({
                    isLive: !1
                });
            }
        });
    },
    onReady: function() {},
    getList: function(t) {
        var e = this;
        wx.showLoading({
            title: "加载中..."
        }), wx.request({
            url: "https://www.120kg.xyz/public/" + t + ".json",
            success: function(t) {
                e.setData({
                    list: t.data.data
                }), wx.hideLoading();
            }
        });
    },
    search: function() {
        wx.navigateTo({
            url: "/pages/searchDetail/index"
        });
    },
    _tab: function(t) {
        var e = t.currentTarget.dataset, a = e.key, s = e.index, o = e.href;
        if (this.data.currentTab === s) return !1;
        this.setData({
            currentTab: s,
            key: a,
            href: o,
            index: s,
            page: 1
        }), this.getList(a);
    },
    onLoad: function() {
        var t = this;
        this.getList("movie");
        var a = null;
        wx.createInterstitialAd && ((a = wx.createInterstitialAd({
            adUnitId: e.globalData.config.adConfig.homeInterstitialAd
        })).onLoad(function() {}), a.onError(function(t) {}), a.onClose(function() {})), 
        a && setTimeout(function() {
            a.show().catch(function(t) {
                console.error(t);
            });
        }, 1e3), setTimeout(function() {
            t.setData({
                isAdd: !1
            });
        }, 1e4);
    },
    onShareAppMessage: function() {
        return {
            title: "[有人@你] 邀请您一起看免费[电影 | 电视剧]资源",
            path: "pages/index/index",
            imageUrl: "",
            success: function(t) {}
        };
    },
    show: function() {
        this.setData({
            isShow: !0
        });
    },
    hide: function() {
        this.setData({
            isShow: !1
        });
    },
    bannerNav: function(t) {
        switch (t.currentTarget.dataset.type) {
          case "1":
            this.toast.showToast("暂未开放! 敬请期待哦！");
            break;

          case "2":
            wx.previewImage({
                current: this.data.kefu,
                urls: [ this.data.kefu ]
            });
        }
    }
});